package com.briup.jz.web.controller;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.jz.bean.AccountCustomer;
import com.briup.jz.bean.extend.AccountCustomerExtend;
import com.briup.jz.service.AccountCustomerService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(description="accountcustomer(顾客账户明细)相关接口")
@Validated
@RestController
@RequestMapping("/accountcustomer")
public class AccountCustomerController{
	@Autowired
	private AccountCustomerService accountcustomerService;
	
	@ApiOperation(value = "查询所有账户分类")
    @GetMapping("query")
    public Message query(Long id,String status,String type,Long userId){
        List<AccountCustomer> list = accountcustomerService.query(id, status, type, userId);
        return MessageUtil.success(list);
    }
	
	@ApiOperation(value = "通过id删除")
    @GetMapping("deleteById")
    @ApiImplicitParams({
        @ApiImplicitParam(name="id",value = "主键",paramType = "query", required=true),
    })
    public Message deleteById(@NotNull Long id){
		accountcustomerService.deleteById(id);
        return MessageUtil.success("删除成功");
    }

    @ApiOperation(value = "保存或更新地址分类信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value = "主键",paramType = "query"),
            @ApiImplicitParam(name="transferMoney",value = "预处理存款",paramType = "query"),
            @ApiImplicitParam(name="transferTime",value = "预处理存款时间",paramType = "query"),
            @ApiImplicitParam(name="description",value = "预处理存款描述",paramType = "query"),
            @ApiImplicitParam(name="type",value = "类型",paramType = "query"),
            @ApiImplicitParam(name="status",value = "情况",paramType = "query"),
            @ApiImplicitParam(name="userId",value = "用户id",paramType = "query"),
//            @ApiImplicitParam(name="isDefault",value = "是否默认，1为默认地址",paramType = "query"),
//            @ApiImplicitParam(name="userId",value = "用户编号",paramType = "query"),
    })
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(AccountCustomer accountcustomer){
    	accountcustomerService.saveOrUpdate(accountcustomer);
        return MessageUtil.success("更新成功");
    }
    @PostMapping("recharge")
    @ApiOperation("顾客充值")
    @ApiImplicitParams({
        @ApiImplicitParam(name="customerId",value="顾客编号 ", paramType = "query",dataType="long",required=true),
        @ApiImplicitParam(name="money",value = "充值金额",paramType = "query",required=true),
        })
    public Message recharge(Long customerId,Double money) {
		return MessageUtil.success("");
	}
    
    @ApiOperation(value="多条件符合级联查询",notes="级联查询出账户记录所属的用户")
    @ApiImplicitParams({
    		@ApiImplicitParam(name="status",value="状态[正常、异常]",paramType="query"),
    		@ApiImplicitParam(name="type",value="类型[充值、消费]",paramType="query"),
    		@ApiImplicitParam(name="userId",value="所属用户id",paramType="query",dataType="Long"),
    	})
    	@GetMapping("queryCascade")
        public Message queryCascade(String status,String type,Long userId){
    		List<AccountCustomerExtend> list = accountcustomerService.queryCascade(status, type, userId);
            return MessageUtil.success(list);
        }
    

}